package access;

import java.io.FileInputStream;
import java.util.Scanner;

public class User {
	private String Username = null;
	private String Password = null;
	private Access_Level grantedAccess = Access_Level.GUEST;
	
	final private String baseValue = "empty";
	
	public User() {
		Username = baseValue;
		Password = baseValue;
		grantedAccess = Access_Level.GUEST;
	}
	public User(String a_User,String a_ALevel, FileInputStream Kin,Scanner Sin) {
		Username = a_User;
		grantedAccess = Access_Level.valueOf(a_ALevel);
		loadPass(Kin,Sin);
	}
	public void set (String a_User,String a_Pass,String a_ALevel) {
		Username = a_User;
		Password = a_Pass;
		grantedAccess = Access_Level.valueOf(a_ALevel);
	}
	public final String getUser() {return Username;}
	public final String getPass() {return Password;}
	
	public final void makeNewPair() {
		
	}
	
	public final void deletePair() {
		
	}
	
	public final void loadPass(FileInputStream keyringInput,Scanner Sin) {
		Sin.useDelimiter("▬");
	    String S;
	    while(Sin.hasNext()) {
	    	S = Sin.next();
	    	if(S.equals(Username)) {
	    		Password = Sin.next();
	    		break;
	    	}
	    }
	}
	
	public final void savePair() {
		
	}
	public Access_Level getAccessLevel() {
		return grantedAccess;
	}
	
	public void clear() {
		Username = baseValue;
		Password = baseValue;
		grantedAccess = Access_Level.GUEST;
	}
	
	public void setUsername(String a_User) {
		Username = a_User;
	}
	
	public void setPassword(String a_Pass) {
		Password = a_Pass;
	}
}